//--------------------------全局变量-------------------------------------
//判定浏览器类型
var isQuirks = document.compatMode == "BackCompat";
var isStrict = document.compatMode == "CSS1Compat";
var isGecko = navigator.userAgent.toLowerCase().indexOf("gecko") != -1;
var isChrome = navigator.userAgent.toLowerCase().indexOf("chrome") != -1;
var isOpera = navigator.userAgent.toLowerCase().indexOf("opera") != -1;
var isIE = navigator.userAgent.toLowerCase().indexOf("msie") != -1 && !isOpera;
var isIE8 = navigator.userAgent.toLowerCase().indexOf("msie 8") != -1 && !!window.XDomainRequest && !!document.documentMode;
var isIE7 = navigator.userAgent.toLowerCase().indexOf("msie 7") != -1 && !isIE8;
var isIE6 = isIE && parseInt(navigator.userAgent.split(";")[1].replace(/(^\s*)|(\s*$)/g, "").split(" ")[1]) < 7;
var isBorderBox = isIE && isQuirks;
var hostProtocol = window.location.protocol;
var hosthostname = window.location.hostname;
var webUrl = hostProtocol + "//www.haitaogoods.com/";
var myUrl = hostProtocol +"//h5.haitaogoods.com/";
var hostUrl = hostProtocol + "//h5.haitaogoods.com/cnfcplathht/mobile/";
var webChatAppId = "wxa1b62742271861bd";
var qqAppId = "101248179";

//js获取网站根路径(站点及虚拟目录)，获得网站的根目录或虚拟目录的根地址
function getRootPath() {
    var strFullPath = window.document.location.href;
    var strPath = window.document.location.pathname;
    var pos = strFullPath.indexOf(strPath);
    var prePath = strFullPath.substring(0, pos);
    var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
    return (prePath + postPath);
}


//js获取网站根路径(站点及虚拟目录)，获得网站的根目录或虚拟目录的根地址
function getWebRootPath() {
    return "";
}

//=================================自动加载脚本，样式等===================
var Server = {};
Server.ContextPath = getRootPath() + "/src/";
//Server.ContextPath = getRootPath() + "/";
//Server.ContextPath = getWebRootPath() + "/";
//Server.ContextPath = "/";//没有虚拟目录
//Server.ContextPath = "";//没有虚拟目录

Server.importScript = function (url) {
    var _rnd = (new Date()).valueOf();
    if (!document.body) {
        document.write('<script type="text/javascript" src="' + Server.ContextPath + url + '"><\/script>');
    } else {
        Server.loadScript(Server.ContextPath + url);
    }
};
Server.importCSS = function (url) {
    var _rnd = (new Date()).valueOf();//+ '?'+_rnd
    if (!document.body) {
        document.write('<link rel="stylesheet" type="text/css" href="' + Server.ContextPath + url + '" />');
    } else {
        Server.loadCSS(Server.ContextPath + url);
    }
};
Server.loadScript = function (url) {//在页面载入后添加script
    var e = document.createElement('SCRIPT');
    e.type = 'text/javascript';
    e.src = url;
    e.defer = true;
    document.getElementsByTagName("HEAD")[0].appendChild(e);
};
Server.loadCSS = function (url) {//在页面载入后添加script
    if (isGecko) {
        var e = document.createElement('LINK');
        e.rel = 'stylesheet';
        e.type = 'text/css';
        e.href = url;
        e.charset = 'gb2312';
        document.getElementsByTagName("HEAD")[0].prependChild(e);

    } else {
        document.createStyleSheet(url);
    }
};

//==================================自动加载样式脚本等=================


/*START_LOADSCRIPT*/
if (!window.DisableScriptAutoLoad) {
    var $base = document.getElementById('base');
    var commonJs = $base.getAttribute('data-js')||'';
    var pageCss = $base.getAttribute('data-css')||'';
    var needDate = $base.getAttribute('data-date')||'';
    var picker = $base.getAttribute('data-picker')||'';
    var validate = $base.getAttribute('data-validate')||'';

    //加载公共样式表
    Server.importCSS("../../static/wechat/plugins/mui/css/mui.min.css");
    if(needDate!=''){
        Server.importCSS("../../static/wechat/plugins/mui/css/mui.picker.min.css");
    }
    if(picker!=''){
        Server.importCSS("../../static/wechat/plugins/mui/css/mui.picker.all.css");
    }

    if(pageCss!=''){
        Server.importCSS(pageCss);
    }


    //加载公共脚本
    Server.importScript("../../static/wechat/plugins/hotcss/hotcss.js");
    Server.importScript("../../static/wechat/plugins/jquery/jquery-1.10.2.min.js");
    Server.importScript("../../static/wechat/plugins/jquery/jquery.md5.js");
    if(validate!=''){
        Server.importScript("../../static/wechat/plugins/jquery/jquery-html5Validate-min.js");
    }
    Server.importScript("../../static/wechat/plugins/mui/js/mui.min.js");
    if(commonJs!=''){
        Server.importScript(commonJs);
    }
    if(needDate!=''){
        Server.importScript("../../static/wechat/plugins/mui/js/mui.picker.min.js");
    }
    if(picker!=''){
        Server.importScript("../../static/wechat/plugins/mui/js/mui.picker.all.js");
    }
}





